package ${basePackage}.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import ${basePackage}.dto.${methodName}DTO;
import ${basePackage}.service.${methodName}Service;
import ${basePackage}.vo.${methodName}VO;
import ${basePackage}.vo.PagerVO;

import java.util.List;

/**
 * @author: sovy
 * @date: ${createTime}
 * @description:
 */
@AllArgsConstructor
@RestController
@Api(description = "${methodName}Controller", tags = "${methodName}", value = "${methodName}Controller")
public class ${methodName}Controller {

    private ${methodName}Service ${defineName}Service;

    @ApiOperation(value = "列表", notes = "列表")
    @GetMapping("/${defineName}s")
    public PagerVO<${methodName}VO> list(
            @ApiParam(value = "当前页") @RequestParam(required = false, defaultValue = "1") int page,
            @ApiParam(value = "每页显示数量") @RequestParam(required = false, defaultValue = "10") int pageSize
    ) {
        return ${defineName}Service.list(page, pageSize);
    }

    @ApiOperation(value = "详情", notes = "详情")
    @GetMapping("/${defineName}s/{id}")
    public ${methodName}VO detail(
            @ApiParam(value = "id") @PathVariable Integer id
    ) {
        return ${defineName}Service.get${methodName}VO(id);
    }

    @ApiOperation(value = "增加", notes = "增加")
    @PostMapping("/${defineName}s")
    public void add(
            @ApiParam(value = "表单详情") @RequestBody ${methodName}DTO ${defineName}DTO
    ) {
        ${defineName}Service.save(${defineName}DTO);
    }

    @ApiOperation(value = "编辑", notes = "编辑")
    @PutMapping("/${defineName}s")
    public void edit(
            @ApiParam(value = "表单详情") @RequestBody ${methodName}DTO ${defineName}DTO
    ) {
        ${defineName}Service.save(${defineName}DTO);
    }

    @ApiOperation(value = "删除", notes = "删除")
    @DeleteMapping("/${defineName}s/{id}")
    public void delete(
            @ApiParam(value = "id") @PathVariable Integer id
    ) {
        ${defineName}Service.delete(id);
    }

    @ApiOperation(value = "批量删除", notes = "批量删除")
    @DeleteMapping("/${defineName}s/{ids}")
    public void delete(
            @ApiParam(value = "ids") @PathVariable List<Integer> ids
    ) {
        ${defineName}Service.delete(ids);
    }

}